
package cn.iocoder.yudao.module.system.controller.admin.agent;
import cn.iocoder.yudao.module.system.controller.admin.agent.vo.PostJdReqVO;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostSaveReqVO;
import cn.iocoder.yudao.module.system.service.agent.AgentService;
import cn.iocoder.yudao.module.system.util.agent.CustomInfoBuild;
import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;


@RestController
@RequestMapping("/system/agent")
public class AgentController {

    @Autowired
    AgentService agentService;

    //提供一个接口或者方法，京东保存订单后执行
    @PostMapping("/jdOrderFinish")
    @Operation(summary = "天翼云接口")
    public String jdOrderFinish(@RequestBody PostJdReqVO createReqVO) {
        String res = agentService.jdOrderFinish(createReqVO);
        return res;
    }



//
//    //查询云桌面资源池
    @RequestMapping("/queryWorkSpaceRegions")
    @ResponseBody
    public String queryWorkSpaceRegions() {
        Map<String, Object> customInfoMap =null ;//null;customInfoBuild.buildCustomInfo();
        Map<String, Object> headerMap = new HashMap<>();
        headerMap.put("customInfo", customInfoMap);
        agentService.queryWorkSpaceRegions(headerMap);
        return null;
    }
//
//    @RequestMapping("/createDefaultVPC")
//    @ResponseBody
//    public String createDefaultVPC() {
//        Map<String, Object> headerMap = new HashMap<>();
//        //1.requestBody：请参考接口文档填写以下内容
//        Map<String, Object> requestBody = new HashMap<>();
//        //是否添加外网访问安全组规则 取值范围：true或false 如果不传默认为true
//        requestBody.put("addExtraSecurityGroupRules", true);
//        //资源池ID，请根据查询资源池列表接口返回值进行传参，获取“regionId”参数
//        requestBody.put("regionId", "xxxxxxxxxxxxxxx");
//        //可用区标识,，请根据查询资源池列表接口返回值进行传参，获取“zoneId”参数
//        requestBody.put("zoneId", "xxxxxxxxxxxxxxx");
//        Map<String, Object> customInfoMap =customInfoBuild.buildCustomInfoAndIdentity();
//        requestBody.put("customInfo", customInfoMap);
//        String body = JSONObject.toJSONString(requestBody);
//        String res = agentService.createDefaultVPC(headerMap,body);
//        return res;
//    }
//
//    @RequestMapping("/queryVPCDetail")
//    public String queryVPCDetail() {
//        Map<String, Object> customInfoMap =customInfoBuild.buildCustomInfoAndIdentity();
//        Map<String, Object> headerMap = new HashMap<>();
//        headerMap.put("regionId", "xxxxxxxxxxxxxxx");
//        headerMap.put("vpcId", "xxxxxxxxxxxxxxx");
//        headerMap.put("projectId", "xxxxxxxxxxxxxxx");
//        headerMap.put("customInfo", customInfoMap);
//        String res = agentService.queryVPCDetail(headerMap);
//        return res;
//    }
//
//    @RequestMapping("/createSubnet")
//    public String createSubnet() {
//        Map<String, Object> headerMap = new HashMap<>();
//        //1.requestBody：请参考接口文档填写以下内容
//        Map<String, Object> requestBody = new HashMap<>();
//
//        Map<String, Object> jsonStr = new HashMap<>();
//        jsonStr.put("regionId", "xxxxxxxxxxxxxxx");
//        jsonStr.put("zoneId", "xxxxxxxxxxxxxxx");
//        jsonStr.put("name", "xxxxxxxxxxxxxxx");
//        jsonStr.put("cidr", "xxxxxxxxxxxxxxx");
//        jsonStr.put("gatewayIp", "xxxxxxxxxxxxxxx");
//        //是否开启自动分配Ip地址，取值范围：true（开启）；false（关闭）
//        jsonStr.put("dhcpEnable", "xxxxxxxxxxxxxxx");
//        jsonStr.put("vpcId", "xxxxxxxxxxxxxxx");
//        jsonStr.put("primaryDns", "xxxxxxxxxxxxxxx");
//        jsonStr.put("secondaryDns", "xxxxxxxxxxxxxxx");
//        requestBody.put("jsonStr", jsonStr);
//        Map<String, Object> customInfoMap =customInfoBuild.buildCustomInfoAndIdentity();
//        requestBody.put("customInfo", customInfoMap);
//        String body = JSONObject.toJSONString(requestBody);
//        String res = agentService.createSubnet(headerMap,body);
//        return res;
//    }
//    @RequestMapping("/querySubnetDetail")
//    public String querySubnetDetail() {
//        Map<String, Object> customInfoMap =customInfoBuild.buildCustomInfoAndIdentity();
//        Map<String, Object> headerMap = new HashMap<>();
//        headerMap.put("regionId", "xxxxxxxxxxxxxxx");
//        headerMap.put("subnetId", "xxxxxxxxxxxxxxx");
//        headerMap.put("projectId", "xxxxxxxxxxxxxxx");
//        headerMap.put("customInfo", customInfoMap);
//        String res = agentService.querySubnetDetail(headerMap);
//        return res;
//    }
//
//    @RequestMapping("/createCloudDesktopService")
//    public String createCloudDesktopService() {
//        Map<String, Object> headerMap = new HashMap<>();
//        //1.requestBody：请参考接口文档填写以下内容
//        Map<String, Object> requestBody = new HashMap<>();
//        requestBody.put("regionId", "xxxxxxxxxxxxxxx");
//        Map<String, Object> customInfoMap =customInfoBuild.buildCustomInfoAndIdentity();
//        requestBody.put("customInfo", customInfoMap);
//        Map<String, Object> createInfo = new HashMap<>();
//        createInfo.put("availability_zone", "xxxxxxxxxxxxxxx");
//        createInfo.put("vpc_id", "xxxxxxxxxxxxxxx");
//        createInfo.put("access_mode", "xxxxxxxxxxxxxxx");
//        Map<String, Object> ad_domains = new HashMap<>();
//        ad_domains.put("domain_type", "xxxxxxxxxxxxxxx");
//        //是否开启自动分配Ip地址，取值范围：true（开启）；false（关闭）
//        ad_domains.put("domain_name", "xxxxxxxxxxxxxxx");
//        ad_domains.put("domain_admin_account", "xxxxxxxxxxxxxxx");
//        ad_domains.put("domain_password", "xxxxxxxxxxxxxxx");
//        ad_domains.put("active_dns_ip", "xxxxxxxxxxxxxxx");
//        ad_domains.put("active_domain_ip", "xxxxxxxxxxxxxxx");
//        createInfo.put("ad_domains",ad_domains);
//        Map<String, Object> subnet_ids = new HashMap<>();
//        subnet_ids.put("subnet_id", "xxxxxxxxxxxxxxx");
//        createInfo.put("subnet_ids",subnet_ids);
//        requestBody.put("createInfo", createInfo);
//        String body = JSONObject.toJSONString(requestBody);
//        String res = agentService.createCloudDesktopService(headerMap,body);
//        return res;
//    }
//
//    @RequestMapping("/getWorkspaceJob")
//    public String getWorkspaceJob() {
//        Map<String, Object> customInfoMap =customInfoBuild.buildCustomInfoAndIdentity();
//        Map<String, Object> headerMap = new HashMap<>();
//        headerMap.put("regionId", "xxxxxxxxxxxxxxx");
//        headerMap.put("jobId", "xxxxxxxxxxxxxxx");
//        headerMap.put("customInfo", customInfoMap);
//        String res = agentService.getWorkspaceJob(headerMap);
//        return res;
//    }
//
//    @RequestMapping("/queryCpcRegionDetail")
//    public String queryCpcRegionDetail() {
//        Map<String, Object> customInfoMap =customInfoBuild.buildCustomInfoAndIdentity();
//        Map<String, Object> headerMap = new HashMap<>();
//        headerMap.put("regionType", "xxxxxxxxxxxxxxx");
//        headerMap.put("regionId", "xxxxxxxxxxxxxxx");
//        headerMap.put("jobId", "xxxxxxxxxxxxxxx");
//        headerMap.put("email", "xxxxxxxxxxxxxxx");
//        headerMap.put("customInfo", customInfoMap);
//        String res = agentService.queryCpcRegionDetail(headerMap);
//        return res;
//    }
//
//    @RequestMapping("/getImages")
//    public String getImages() {
//        Map<String, Object> customInfoMap =customInfoBuild.buildCustomInfoAndIdentity();
//        Map<String, Object> headerMap = new HashMap<>();
//        headerMap.put("regionId", "xxxxxxxxxxxxxxx");
//        headerMap.put("platformType", "xxxxxxxxxxxxxxx");
//        headerMap.put("osBit", "xxxxxxxxxxxxxxx");
//        headerMap.put("supportXen", "xxxxxxxxxxxxxxx");
//        headerMap.put("supportXenGpuType", "xxxxxxxxxxxxxxx");
//        headerMap.put("isVirtual", "xxxxxxxxxxxxxxx");
//        headerMap.put("imageType", "xxxxxxxxxxxxxxx");
//        headerMap.put("supportKvmGpuType", "xxxxxxxxxxxxxxx");
//        headerMap.put("customInfo", customInfoMap);
//        String res = agentService.getImages(headerMap);
//        return res;
//    }
}
